package com.fc.h5dispaly.h5display.viewpager;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.FrameLayout;

import com.fc.h5dispaly.h5display.R;
import com.fc.h5dispaly.h5display.util.Util;

/**
 * Created by fc on 2020/5/13
 * Describe:
 *
 * @author fc
 */
public class VPActivity extends Activity {
    private int[] mImages = {R.mipmap.b, R.mipmap.aiot_bg, R.mipmap.movie_bg, R.mipmap.d, R.mipmap.e, R.mipmap.f};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final IRotationView rotationView = new RotationView(this);
        rotationView.setInterpolator(null);
        rotationView.setDuration(500);
        rotationView.setData(mImages);
        setContentView((FrameLayout) rotationView);

        Button button1 = new Button(this);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        button1.setText("下一页");
        ((FrameLayout) rotationView).addView(button1,params);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                rotationView.nextPage();
            }
        });

        Button button2 = new Button(this);
         params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        button2.setText("前一页");
        params.leftMargin = Util.Div(300);
        ((FrameLayout) rotationView).addView(button2,params);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                rotationView.prevPage();
            }
        });
    }
}
